<template>
  <div>
    <el-radio-group v-model="form.type">
      <el-form :model="form" label-position="left" label-width="160px" size="mini">
        <el-form-item>
          <template v-slot:label>
            <el-radio :label="1" class="time-title">指定天数</el-radio>
          </template>
          <edu-input-number v-show="form.type == 1" :value.sync="form.days" :args="{min:0,max:9999}" />
        </el-form-item>
        <el-form-item>
          <template v-slot:label>
            <el-radio :label="2">指定时间</el-radio>
          </template>
          <edu-date v-show="form.type == 2" :value.sync="form.date" :args="{}" />
        </el-form-item>
      </el-form>
    </el-radio-group>
  </div>
</template>

<script>
import EduInputNumber from '@public/form/input_number';
import EduDate from '@public/form/date'

export default {
  components: {
    EduInputNumber,
    EduDate
  },
  props: {
    value: {
      type: Number,
      default: 0
    },
    field: {
      type: String,
      required: true,
      default: ''
    },
    formDatas: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      form: {
        type: this.$util.getDefValue(this.value.type, 1),
        days: this.$util.getDefValue(this.value.days, 0),
        date: this.$util.getDefValue(this.value.date, '')
      }
      }
  },
  watch: {
    // 更新
    form: {
      handler(val) {
        this.$emit('update:value', val);
      },
      deep: true
    }
  }
};
</script>
